<html>
	<!--
		@author Jean-Lou Dupont 
	 -->
	<head>
		<style>
		/**
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 */
.code .de1, .code .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;}
.code  {background: #EEEEEE; border: padding: 0.2em}
.code .imp {font-weight: bold; color: red;}
.code li, .code li.li1 {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;}
.code li.li2 {font-weight: bold;}
.code .kw1 {color: #b1b100;}
.code .kw2 {color: #000000; font-weight: bold;}
.code .kw3 {color: #000066;}
.code .co1 {color: #808080; font-style: italic;}
.code .co2 {color: #808080; font-style: italic;}
.code .coMULTI {color: #808080; font-style: italic;}
.code .es0 {color: #000099; font-weight: bold;}
.code .br0 {color: #66cc66;}
.code .sy0 {color: #66cc66;}
.code .st0 {color: #ff0000;}
.code .nu0 {color: #cc66cc;}
.code .me1 {color: #006600;}
.code .me2 {color: #006600;}
.code .re0 {color: #0000ff;}
.code .re1 {color: #ff0000}

		</style>
	</head>
	
	<body>
	
		<div id="content">
		<pre class="code" style="background: #EEEEEE; border: padding: 0.2em"><ol><li class="li1"><div class="de1"><span class="kw2">&lt;?php</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">/**</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;* Factory pattern</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;*</span></div></li><li class="li2"><div class="de2"><span class="coMULTI">&nbsp;* Executes this script and see the result</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;* matching the data provided at the bottom.</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;*  </span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;* @author Jean-Lou Dupont</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;* PROJECT SITE: //http://php-design-patterns-examples.googlecode.com/</span></div></li><li class="li2"><div class="de2"><span class="coMULTI">&nbsp;*/</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw2">class</span> Base <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="coMULTI">/**</span></div></li><li class="li2"><div class="de2"><span class="coMULTI">	 * Class map for the factory</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * @access private</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 */</span></div></li><li class="li1"><div class="de1">	<span class="kw2">private</span> <a href="http://www.php.net/static"><span class="kw3">static</span></a> <span class="re1">$classMap</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="coMULTI">/*================================================================</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 					PUBLIC INTERFACE</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 ================================================================*/</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">	<span class="coMULTI">/**</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * Maps a class to another one</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * Used along with the factory interface.</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * </span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * @param $oClasse string original class</span></div></li><li class="li2"><div class="de2"><span class="coMULTI">	 * @param $rClasse string replacement class</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * @return void</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 */</span></div></li><li class="li1"><div class="de1">	<span class="kw2">public</span> <a href="http://www.php.net/static"><span class="kw3">static</span></a> <span class="kw2">function</span> mapClass<span class="br0">&#40;</span> <span class="re1">$oClasse</span><span class="sy0">,</span> <span class="re1">$rClasse</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">		self<span class="sy0">::</span><span class="re1">$classMap</span><span class="br0">&#91;</span> <span class="re1">$oClasse</span> <span class="br0">&#93;</span> <span class="sy0">=</span> <span class="re1">$rClasse</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">	<span class="coMULTI">/**</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * factory</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * </span></div></li><li class="li2"><div class="de2"><span class="coMULTI">	 * @param $className name of class to instantiate/get (singleton)</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * @param mixed optional parameters</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * @return $object</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 */</span></div></li><li class="li1"><div class="de1">	<span class="kw2">public</span> <a href="http://www.php.net/static"><span class="kw3">static</span></a> <span class="kw2">function</span> factory<span class="br0">&#40;</span> <span class="re1">$className</span> <span class="coMULTI">/*optional params*/</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">		<span class="re1">$args</span> <span class="sy0">=</span> <a href="http://www.php.net/func_get_args"><span class="kw3">func_get_args</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">		<a href="http://www.php.net/array_shift"><span class="kw3">array_shift</span></a><span class="br0">&#40;</span> <span class="re1">$args</span> <span class="br0">&#41;</span><span class="sy0">;</span>	<span class="co2">#get rid of $classname</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">		<span class="re1">$classe</span> <span class="sy0">=</span> self<span class="sy0">::</span><span class="me2">map</span><span class="br0">&#40;</span> <span class="re1">$className</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">		<span class="kw1">return</span> self<span class="sy0">::</span><span class="me2">buildObject</span><span class="br0">&#40;</span> <span class="re1">$classe</span><span class="sy0">,</span> <span class="re1">$args</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="coMULTI">/*================================================================</span></div></li><li class="li2"><div class="de2"><span class="coMULTI">	 					PRIVATE INTERFACE</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 ================================================================*/</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="coMULTI">/**</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * Maps class-name</span></div></li><li class="li2"><div class="de2"><span class="coMULTI">	 * @param string $className</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * @return string $out_class</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 */</span></div></li><li class="li1"><div class="de1">	<span class="kw2">private</span> <a href="http://www.php.net/static"><span class="kw3">static</span></a> <span class="kw2">function</span> map<span class="br0">&#40;</span> <span class="sy0">&amp;</span><span class="re1">$className</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">		<span class="co1">// check our replacement map</span></div></li><li class="li1"><div class="de1">		<span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span> self<span class="sy0">::</span><span class="re1">$classMap</span><span class="br0">&#91;</span><span class="re1">$className</span><span class="br0">&#93;</span> <span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">			<span class="re1">$classe</span> <span class="sy0">=</span> self<span class="sy0">::</span><span class="re1">$classMap</span><span class="br0">&#91;</span><span class="re1">$className</span><span class="br0">&#93;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">			<span class="co1">// autoloads &amp; verifies existence</span></div></li><li class="li1"><div class="de1">			<span class="kw1">if</span> <span class="br0">&#40;</span> <span class="sy0">!</span><a href="http://www.php.net/class_exists"><span class="kw3">class_exists</span></a><span class="br0">&#40;</span> <span class="re1">$classe</span><span class="sy0">,</span> <span class="kw2">true</span> <span class="br0">&#41;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">				throw <span class="kw2">new</span> Exception<span class="br0">&#40;</span> <span class="st0">&quot;unable to load class ($className) remapped to ($classe)&quot;</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">			<span class="kw1">return</span> <span class="re1">$classe</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">		<span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">		<span class="co1">// default i.e. no remapping</span></div></li><li class="li1"><div class="de1">		<span class="kw1">if</span> <span class="br0">&#40;</span> <span class="sy0">!</span><a href="http://www.php.net/class_exists"><span class="kw3">class_exists</span></a><span class="br0">&#40;</span> <span class="re1">$className</span><span class="sy0">,</span> <span class="kw2">true</span> <span class="br0">&#41;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">			throw <span class="kw2">new</span> Exception<span class="br0">&#40;</span> <span class="st0">&quot;unable to load class $className&quot;</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">		<span class="co1">// if no mapping is required</span></div></li><li class="li1"><div class="de1">		<span class="kw1">return</span> <span class="re1">$className</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">	<span class="coMULTI">/**</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * Builds an object instance of the specified class</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * and passes properly a variable argument list</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * </span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * @param $classe</span></div></li><li class="li2"><div class="de2"><span class="coMULTI">	 * @param $args mixed</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * @return $object</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 * @throws aop_exception when too many arguments are passed in array $args</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">	 */</span></div></li><li class="li1"><div class="de1">	<span class="kw2">private</span> <a href="http://www.php.net/static"><span class="kw3">static</span></a> <span class="kw2">function</span> buildObject<span class="br0">&#40;</span> <span class="sy0">&amp;</span><span class="re1">$classe</span><span class="sy0">,</span> <a href="http://www.php.net/array"><span class="kw3">Array</span></a> <span class="sy0">&amp;</span><span class="re1">$args</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">		<span class="re1">$count</span> <span class="sy0">=</span> <a href="http://www.php.net/count"><span class="kw3">count</span></a><span class="br0">&#40;</span> <span class="re1">$args</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">		<span class="kw1">switch</span><span class="br0">&#40;</span> <span class="re1">$count</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">		<span class="kw1">case</span> <span class="nu0">0</span><span class="sy0">:</span></div></li><li class="li2"><div class="de2">			<span class="kw1">return</span> <span class="kw2">new</span> <span class="re1">$classe</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">		<span class="kw1">case</span> <span class="nu0">1</span><span class="sy0">:</span></div></li><li class="li1"><div class="de1">			<span class="kw1">return</span> <span class="kw2">new</span> <span class="re1">$classe</span><span class="br0">&#40;</span> <span class="re1">$args</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">		<span class="kw1">case</span> <span class="nu0">2</span><span class="sy0">:</span></div></li><li class="li1"><div class="de1">			<span class="kw1">return</span> <span class="kw2">new</span> <span class="re1">$classe</span><span class="br0">&#40;</span> <span class="re1">$args</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="re1">$args</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">		<span class="kw1">case</span> <span class="nu0">3</span><span class="sy0">:</span></div></li><li class="li1"><div class="de1">			<span class="kw1">return</span> <span class="kw2">new</span> <span class="re1">$classe</span><span class="br0">&#40;</span> <span class="re1">$args</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="re1">$args</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="re1">$args</span><span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">		<span class="kw1">case</span> <span class="nu0">4</span><span class="sy0">:</span></div></li><li class="li1"><div class="de1">			<span class="kw1">return</span> <span class="kw2">new</span> <span class="re1">$classe</span><span class="br0">&#40;</span> <span class="re1">$args</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="re1">$args</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="re1">$args</span><span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="re1">$args</span><span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">		<span class="kw2">default</span><span class="sy0">:</span></div></li><li class="li2"><div class="de2">			throw <span class="kw2">new</span> Exception<span class="br0">&#40;</span> <span class="st0">&quot;unsupported number of arguments whilst creating object in factory&quot;</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">		<span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">	<span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2"><span class="br0">&#125;</span><span class="co1">//end class</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="coMULTI">/*****************************************************************</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;* 						EXAMPLE                                  *</span></div></li><li class="li2"><div class="de2"><span class="coMULTI">&nbsp;*****************************************************************/</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw2">class</span> Test1 <span class="br0">&#123;</span><span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw2">class</span> Test2 <span class="br0">&#123;</span><span class="br0">&#125;</span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw2">class</span> Test3 <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="kw2">var</span> <span class="re1">$p1</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw2">var</span> <span class="re1">$p2</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="kw2">public</span> <span class="kw2">function</span> __construct<span class="br0">&#40;</span> <span class="re1">$required_param1</span><span class="sy0">,</span> <span class="re1">$required_param2</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">		<span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">p1</span> <span class="sy0">=</span> <span class="re1">$required_param1</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">		<span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">p2</span> <span class="sy0">=</span> <span class="re1">$required_param2</span><span class="sy0">;</span>		</div></li><li class="li1"><div class="de1">	<span class="br0">&#125;</span></div></li><li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw2">class</span> Test4 <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="kw2">var</span> <span class="re1">$p1</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">	<span class="kw2">var</span> <span class="re1">$p2</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="kw2">var</span> <span class="re1">$p3</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">	<span class="kw2">public</span> <span class="kw2">function</span> __construct<span class="br0">&#40;</span> <span class="re1">$required_param1</span><span class="sy0">,</span> <span class="re1">$required_param2</span><span class="sy0">,</span> <span class="re1">$optional_param</span> <span class="sy0">=</span> <span class="kw2">null</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">		<span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">p1</span> <span class="sy0">=</span> <span class="re1">$required_param1</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2">		<span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">p2</span> <span class="sy0">=</span> <span class="re1">$required_param2</span><span class="sy0">;</span>		</div></li><li class="li1"><div class="de1">		<span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">p3</span> <span class="sy0">=</span> <span class="re1">$optional_param</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">	<span class="br0">&#125;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2"><span class="co1">// simple case</span></div></li><li class="li1"><div class="de1"><span class="re1">$o1</span> <span class="sy0">=</span> Base<span class="sy0">::</span><span class="me2">factory</span><span class="br0">&#40;</span> <span class="st0">'Test1'</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;o1: class=  &quot;</span><span class="sy0">.</span><a href="http://www.php.net/get_class"><span class="kw3">get_class</span></a><span class="br0">&#40;</span> <span class="re1">$o1</span> <span class="br0">&#41;</span><span class="sy0">.</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="co1">// remapping case</span></div></li><li class="li2"><div class="de2">Base<span class="sy0">::</span><span class="me2">mapClass</span><span class="br0">&#40;</span> <span class="st0">'Test1'</span><span class="sy0">,</span> <span class="st0">'Test2'</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="re1">$o2</span> <span class="sy0">=</span> Base<span class="sy0">::</span><span class="me2">factory</span><span class="br0">&#40;</span> <span class="st0">'Test1'</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;o2: class=  &quot;</span><span class="sy0">.</span><a href="http://www.php.net/get_class"><span class="kw3">get_class</span></a><span class="br0">&#40;</span> <span class="re1">$o2</span> <span class="br0">&#41;</span><span class="sy0">.</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="co1">// remapping &amp; creation with parameters case</span></div></li><li class="li2"><div class="de2">Base<span class="sy0">::</span><span class="me2">mapClass</span><span class="br0">&#40;</span> <span class="st0">'Test3'</span><span class="sy0">,</span> <span class="st0">'Test4'</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="re1">$o3</span> <span class="sy0">=</span> Base<span class="sy0">::</span><span class="me2">factory</span><span class="br0">&#40;</span> <span class="st0">'Test3'</span><span class="sy0">,</span> <span class="st0">'req_param1'</span><span class="sy0">,</span> <span class="st0">'req_param2'</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;o3: class=  &quot;</span><span class="sy0">.</span><a href="http://www.php.net/get_class"><span class="kw3">get_class</span></a><span class="br0">&#40;</span> <span class="re1">$o3</span> <span class="br0">&#41;</span><span class="sy0">.</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;o3: param1= &quot;</span><span class="sy0">.</span><span class="re1">$o3</span><span class="sy0">-&gt;</span><span class="me1">p1</span><span class="sy0">.</span><span class="st0">&quot; param2= &quot;</span><span class="sy0">.</span><span class="re1">$o3</span><span class="sy0">-&gt;</span><span class="me1">p2</span><span class="sy0">.</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">__halt_compiler<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">/*****************************************************************</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;* 						RESULTS                                  *</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp;*****************************************************************/</span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">o1<span class="sy0">:</span> <span class="kw2">class</span><span class="sy0">=</span>  Test1</div></li><li class="li1"><div class="de1">o2<span class="sy0">:</span> <span class="kw2">class</span><span class="sy0">=</span>  Test2</div></li><li class="li1"><div class="de1">o3<span class="sy0">:</span> <span class="kw2">class</span><span class="sy0">=</span>  Test4</div></li><li class="li1"><div class="de1">o3<span class="sy0">:</span> param1<span class="sy0">=</span> req_param1 param2<span class="sy0">=</span> req_param2</div></li><li class="li2"><div class="de2">&nbsp;</div></li></ol></pre>
		</div>
	</body>

</html>
